/**
 * @file
 * @author Filipe Mutz
 *
 * @section DESCRIPTION
 * This file defines the image class. I created that class to isolate the OpenCV dependency to this file.
 *
 * @section TODO
 * 1. Create a base class to Color and Gray and create abstract methods get and set in the abstract class Image.
 */

#ifndef IMAGE_H_
#define IMAGE_H_

#include <cstdlib>
#include <time.h>

#include <opencv/cv.h>
#include <opencv/highgui.h>


namespace brain
{
	namespace image
	{

		class Color
		{
			public:

				int red_intensity;
				int green_intensity;
				int blue_intensity;
		};


		class Gray
		{
			public:

				int intensity;
		};


		class Image
		{
			protected:

				char _img_id[32]; // its used to index the window in the show method
				IplImage *_img;

				void read(char *filename, int format);
				int get_pixel_position(int i, int j);

			public:

				Image();
				Image(Image &img);
				virtual ~Image();

				Image& operator=(const Image &img);

				virtual void read(char *filename) = 0;
				void save(char *filename) const;

				int show() const;
				int show(int delay) const;

				int width() const;
				int height() const;
		};


		class GrayscaleImage: public Image
		{
			public:

				GrayscaleImage();
				~GrayscaleImage();

				void read(char *filename);

				Gray get (int i, int j);
				void set(int i, int j, Gray gray);

				void draw_point(int i, int j);
		};


		class ColorImage: public Image
		{
			public:

				ColorImage();
				~ColorImage();

				void read(char *filename);

				Color get (int i, int j);
				void set(int i, int j, Color color);

				void draw_point(int i, int j);
		};
	}
}

#endif
